package cn.heygod.graywhale.runtime.script.controller;

import cn.heygod.graywhale.common.web.base.BaseController;
import cn.heygod.graywhale.runtime.context.Input;
import cn.heygod.graywhale.runtime.context.Output;
import cn.heygod.graywhale.runtime.script.JavaScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Describe:
 * Author:
 * CreateTime:
 */
@RestController
@RequestMapping("/gw/script")
public class ScriptController extends BaseController {

    @Autowired
    private JavaScriptService javaScriptService;

    @GetMapping("run-not-params")
    public Output runNotParams(@RequestParam("id") String id){
        Output output = javaScriptService.run(id,new Input());
        return output;
    }

    @PostMapping("run")
    public Output runScript(@RequestBody Input input){

        Output output = javaScriptService.run(input.getId(),input);
        return output;
    }

}
